{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "996865cf",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "from sklearn.linear_model import LinearRegression"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0cd85cdc",
   "metadata": {},
   "source": [
    "### 声明数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "94743ae9",
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[   0],\n",
       "       [ 500],\n",
       "       [1000],\n",
       "       [1500],\n",
       "       [2000],\n",
       "       [2500],\n",
       "       [3000],\n",
       "       [3500],\n",
       "       [4000]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "array([ 12.834044,  10.190649,   5.500229,   2.854665,  -0.706488,\n",
       "        -4.065323,  -7.12748 , -10.058879, -13.206465])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "X = np.arange(0,4001,500,)\n",
    "\n",
    "# X必须是二维数组，reshape\n",
    "X = X.reshape(-1,1)\n",
    "\n",
    "# 温度\n",
    "y = np.array([12.834044,10.190649,5.500229,2.854665,-0.706488,-4.065323,-7.127480,-10.058879,-13.206465])\n",
    "display(X,y)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7443b764",
   "metadata": {},
   "source": [
    "### 线性模型"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "3df0d610",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[-0.00656953] 12.718507511111111\n"
     ]
    }
   ],
   "source": [
    "# fit_intercept=True，拟合，训练，计算截距\n",
    "model = LinearRegression()\n",
    "model.fit(X,y)\n",
    "print(model.coef_,model.intercept_)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "aacd04fb",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[-0.00208065] 0.0\n"
     ]
    }
   ],
   "source": [
    "# fit_intercept=True，拟合，训练，计算截距\n",
    "model = LinearRegression(fit_intercept=False)\n",
    "model.fit(X,y)\n",
    "print(model.coef_,model.intercept_)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0edd312f",
   "metadata": {},
   "source": [
    "### 正规方程"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "12f686fd",
   "metadata": {},
   "source": [
    "#### X是一列求解的结果一个斜率"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3e33e8e8",
   "metadata": {},
   "source": [
    "$W = (X^TX)^{-1}X^Ty$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "8fc3fbac",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([-0.00208065])"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.set_printoptions(suppress=True)\n",
    "np.linalg.inv(X.T.dot(X)).dot(X.T).dot(y)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1cfeb43b",
   "metadata": {},
   "source": [
    "#### X数据进行扩充，增加一列（表示截距）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "7110484a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(9, 1)"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "0119b2d8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[   0,    1],\n",
       "       [ 500,    1],\n",
       "       [1000,    1],\n",
       "       [1500,    1],\n",
       "       [2000,    1],\n",
       "       [2500,    1],\n",
       "       [3000,    1],\n",
       "       [3500,    1],\n",
       "       [4000,    1]])"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X = np.concatenate([X,np.full(shape = (9,1),fill_value=1)],axis = 1)\n",
    "X"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "750f0d06",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([-0.00656953, 12.71850751])"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.set_printoptions(suppress=True)\n",
    "\n",
    "np.linalg.inv(X.T.dot(X)).dot(X.T).dot(y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "2d867c39",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 计算不同海拔的温度，对应的函数\n",
    "def fun(high):\n",
    "    return -0.00656953 * high + 12.71850751"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "13c95f89",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "-26.698672489999993"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fun(6000)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "id": "86ee1151",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 12.834044,  10.190649,   5.500229,   2.854665,  -0.706488,\n",
       "        -4.065323,  -7.12748 , -10.058879, -13.206465])"
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "id": "7ffc7259",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([   0,  500, 1000, 1500, 2000, 2500, 3000, 3500, 4000])"
      ]
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X[:,0].reshape(-1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "id": "60f25dbc",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x1c42e01e490>]"
      ]
     },
     "execution_count": 57,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXkAAAD4CAYAAAAJmJb0AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAAAlZElEQVR4nO3de5hN9eLH8fd3LpjchkyYceuqGTMYBsmlRC4RkhzVKeRuukdRv05OdaIcXY5m3O+kyF0it6JyacYYY0ZOdB/EEYmmMfj+/pit0CDZe6+993xezzPPrL3Wnr0+1h6fZ81aa3+XsdYiIiKBKcjpACIi4jkqeRGRAKaSFxEJYCp5EZEAppIXEQlgIU4HOF25cuVstWrVnI4hIuJXUlNT/2etjShomU+VfLVq1UhJSXE6hoiIXzHGfHOuZTpcIyISwFTyIiIBTCUvIhLAVPIiIgFMJS8iEsB86uqav2JBWjYjlu9g96EcIsPDGNSqOh3jo5yOJSLiE/y65BekZTNkXgY5eScAyD6Uw5B5GQAqehER/PxwzYjlO34r+FNy8k4wYvkOhxKJiPgWvy753YdyAMgze9lX5AXyzN4z5ouIFHZ+XfKR4WEA5Jnv+DVoK3uKJnI4eAEVSxdxOJmIiG/w65If1Ko6YaHBXHayHpG5yRQ7WZODRSZwoPhTbNu3zel4IiKO8+uS7xgfxbBOcUSFhxFqI6gdNozH67zJj7nfUWdsHYZ+OJTc47lOxxQRcYzxpXu8JiQkWHcMUPa/X/7Ho8seZWbGTGpE1GBi+4k0qNTADQlFRHyPMSbVWptQ0DK/3pM/l3KXlWNGpxm8d897/JT7Ew0nNuSxZY9x9NhRp6OJiHhVQJb8KbddexuZAzLpn9Cf1ze+TuzoWFZ+udLpWCIiXhPQJQ9Qqmgpktomsb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4jIOajkRUQCmEpeRCSAqeRFRAKYSl5EJICp5EVEAphKXkQkgP0/XpHKfeWaPeIAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.scatter(X[:,0].reshape(-1),y)\n",
    "\n",
    "x = np.linspace(0,4000,50)\n",
    "\n",
    "y = fun(x)\n",
    "\n",
    "plt.plot(x,y,color = 'green')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "87069523",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.10"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
